<!--	
<div id="user_nav">
  <% if current_user %>
    Logged in as <%= current_user.email %>.
    <%= link_to "Log out", log_out_path %>
  <% else %>
    <%= link_to "Sign up", sign_up_path %> or
    <%= link_to "log in", log_in_path %>
  <% end %>
</div>
-->
<div class = "contentArea">

	<div class = "contentTop">
		<h1>AutoParts.щ</h1>
	</div>
	
	<div class = "content">
	<div class = "contentLeft">

		<%= form_for @request, :url => { :controller => "welcome", :action => "show2" } do |f| %>
		
			<% if @request.errors.any? %>
    			<div class="error_messages">
      				<ul>
						<% for message in @request.errors.full_messages %>
							<li><%= message %></li>
						<% end %>
      				</ul>
				</div>
			<% end %>
		
			
		    <%= f.select :car_brand_id, options_from_collection_for_select(CarBrand.all(:order => :name), 'id', 'name', :selected => @request.car_brand_id), :include_blank => '< Марка >', :required => true %>
		    
		    <div id = "carModels">
				<%= render :partial => 'car_models', :locals => { :car_model_id => @request.car_model_id, :car_models => CarModel.where(:car_brand_id => @request.car_brand_id).order(:name) }  %>
			</div>
			
			<%= f.select :year, options_for_select((1960..2011).to_a.reverse, :selected => @request.year), :include_blank => '< Година >'  %><br />
			<%= f.select :engine_type_id, options_from_collection_for_select(EngineType.all, 'id', 'name', :selected => @request.engine_type_id), :include_blank => '< Mодел >'  %><br />
			<%= f.select :gearbox_type_id, options_from_collection_for_select(GearboxType.all, 'id', 'name', :selected => @request.gearbox_type_id), :include_blank => '< Скоростна кутия >'  %><br />
			<%= f.text_field :gsm, default_text((@request.gsm.nil? ? "GSM" : @request.gsm)) %><br />
			<%= f.text_field :email, default_text((@request.email.nil? ? "e-mail" : @request.email)) %><br />
			<%= autocomplete_field_tag :city_name, '', welcome_autocomplete_city_name_path, :id_element => "#request_city_id" %>
			<%= f.hidden_field :city_id %>
			<%= select_tag("region_ids[]", options_for_select(Region.find(:all).collect { |reg| [reg.name, reg.id] }, @request.region_requests.collect { |reg| reg.region_id }), { :multiple => true, :id => "requestRegions" } )%>
		
			<%= f.submit "Пусни заявка" %>
		<% end %>			
	</div>
	
	<div class = "contentMiddle">
		<%= form_for PartConfiguration.new, :remote => true do |f| %>
			<%= f.autocomplete_field :part_name, welcome_autocomplete_part_name_path, default_text("Напишете частта, която търсите") %><br />
			<%= f.select :used_type_id, options_from_collection_for_select(UsedType.all, 'id', 'name'), :include_blank => '< Използваност на частите >'  %><br />
			<%= f.select :original_type_id, options_from_collection_for_select(OriginalType.all, 'id', 'name'), :include_blank => '< Оригиналност на частите >'  %><br />
			<%= f.hidden_field :cart_id, :value => current_cart.id %>
			
			<%= f.submit 'Добавете' %>
		<% end %>
		 
		<div id="cart">
			<%= render current_cart %>
		</div>
	</div>
	</div>
	
	
	<div class = "contentBottom">
		All rights reserved. Autoparts.щ 2011
	</div>
</div>

<script type="text/javascript">
    $(document).ready(function() {
        $("#requestRegions").multiselect();
    });
</script>
